import { ErrorCode } from "../../src/config/ErrorCode";
import { GameConfig } from "../../src/config/GameConfig";
import { ServerConfig } from "../../src/config/ServerConfig";
import { AccountDao } from "../dao/AccountDao";

const Time_Check_Inteval: number = 1000 * 60 * 60
const Time_Delete_Inteval: number = 1000 * 60 * 60 * 24

export class AccountModel {

    public static phoneCodeMap: Map<string, string> = new Map<string, string>()

    public static async login(account: string, sign: string, callback: Function) {
        let accountResult: object = await AccountDao.get_account_info(account)
        if (accountResult) {
            if (ServerConfig.nowServerConfig.status == ServerConfig.Status_Type.Weihu) {
                if (accountResult["state"] != GameConfig.Status_Type.Test) {
                    callback(ErrorCode.Code.Server_Weihu, "服务器维护")
                    return
                }
            }
            if (sign == accountResult["token"]) {
                callback(ErrorCode.Code.Suc, "")
            } else {
                callback(ErrorCode.Code.LoginError_token, "token错误,请重新登录")
            }
        } else {
            callback(ErrorCode.Code.LoginError_NoUser, "账号不存在")
        }

    }



}